﻿@model SoftHotel.Models.Cliente

@{
    ViewBag.Title = "Create";
}


<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>


<script type="text/javascript">
    function esto(e) {
        var a = e.options[e.selectedIndex].text; //e.value;
        //alert(e.options[e.selectedIndex].text);
        //a = a.split(' ').join('')
        //  alert(a.split(' ').join(''));
        if (a == "Organización") {
            //alert(a);
            document.getElementById("txt").disabled = true;
            document.getElementById("txtApPat").disabled = true;
       //     document.getElementById("email").style.display = '';
       //     document.getElementById("email2").style.display = '';
            document.getElementById("txtApMat").disabled = true;
            document.getElementById("txtRs").disabled = false;
        }
        else if (a == "Persona") {
            //document.getElementById("apMat").style.display = '';
            document.getElementById("txtApMat").disabled = false;
            document.getElementById("txtApPat").disabled = false;
            //document.getElementById("Rs").style.display = 'none';
            document.getElementById("txtRs").disabled = true;
            //document.getElementById("nomb").style.display = '';
            document.getElementById("txt").disabled = false;
        }

    }
</script>

@using (Html.BeginForm())
{
    @Html.ValidationSummary(true)
    <h1><strong>Nuevo Cliente</strong></h1>
    <br />
    <table id="MainContent_Table1" rules="none" style="border-color: Black; width: 900px; margin-bottom: 0px;"> 
            <tr>
                <td style="width: 20px;"></td>
		        <td style="font-weight: bold; width: 220px;">@Html.LabelFor(model => model.tipo) </td>
		        <td style="width: 220px;">
                    @Html.DropDownListFor(Model => Model.tipo, (IEnumerable<SelectListItem>)ViewBag.tipoCliente, "--seleccionar--", new { onchange = "esto(this)" })
		            @Html.ValidationMessageFor(model => model.tipo)
                </td>
            </tr>
            <tr id = "nomb">
		        <td style="width: 20px;"></td>
		        <td style="font-weight: bold; width: 220px;">@Html.LabelFor(model => model.nombres) </td>
		        <td style="width: 220px; display = 'none';">
                    @Html.TextBoxFor(model => model.nombres, new { @class = "required", id = "txt" })
                    @Html.ValidationMessageFor(model => model.nombres)
                </td>
		        <td></td> 
		        <td style="font-weight: bold; width: 220px;">@Html.LabelFor(model => model.apellidoPaterno)</td>
		        <td style="width: 220px;">
                    @Html.TextBoxFor(model => model.apellidoPaterno, new { @class = "required", id = "txtApPat" })
                    @Html.ValidationMessageFor(model => model.apellidoPaterno)    
                </td>
	        </tr>      
            <tr id = apMat>
		        <td style="width: 20px;"></td>
		        <td style="font-weight: bold; width: 220px;">@Html.LabelFor(model => model.apellidoMaterno) </td>
		        <td style="width: 220px;">
                    @Html.TextBoxFor(model => model.apellidoMaterno, new { @class = "required", id = "txtApMat", disabled = "disabled" })
                    @Html.ValidationMessageFor(model => model.apellidoMaterno)
                </td>
		        <td></td> 
		        <td style="font-weight: bold; width: 220px;">@Html.LabelFor(model => model.email)</td>
		        <td style="width: 194px;">
                    @Html.EditorFor(model => model.email)
                    @Html.ValidationMessageFor(model => model.email)
                </td>
	        </tr>      
            <tr id = "Rs">
		        <td style="width: 20px;"></td>
		        <td style="font-weight: bold; width: 220px;">@Html.LabelFor(model => model.razonsocial)</td>
		        <td style="width: 220px;">
                    @Html.TextBoxFor(model => model.razonsocial, new { @class = "required", id = "txtRs" })
                    @Html.ValidationMessageFor(model => model.razonsocial)
                </td>
		        <td></td> 
		        <td style="font-weight: bold; width: 220px;">@Html.LabelFor(model => model.tipoDoc)</td>
		        <td style="width: 220px;">
                    @Html.DropDownListFor(Model => Model.tipoDoc, (IEnumerable<SelectListItem>)ViewBag.tipoDoc, "-select-", new { @class = "required" })
                    @Html.ValidationMessageFor(model => model.tipoDoc)
                </td>
	        </tr>   
            <tr>
		        <td style="width: 20px;"></td>
		        <td style="font-weight: bold; width: 1000px;">@Html.LabelFor(model => model.numDoc)</td>
		        <td style="width: 100px;">
                    @Html.EditorFor(model => model.numDoc)
                    @Html.ValidationMessageFor(model => model.numDoc)
                </td>
                <td></td> 
                <td></td>
                <td></td>
	        </tr>   
    </table>
        <p>
            <input type="submit" value="Create" name = "button"/>
            
        </p>
}

<div>
    @Html.ActionLink("Regresar", "Index")
</div>
